<?php
namespace app\index\controller;

use think\Controller;
use app\index\service\UserService;
class User extends Controller
{
    private $userService;

    /**
     * 依赖注入 Service
     *
     * @param UserService $userService
     * @author zws
     */
    public function __construct(UserService $userService)
    {
        $this->userService = $userService;
        parent::__construct();
    }

    /**
     * 注册
     * @return \think\response\Json
     * @author zws
     */
    public function register()
    {
        $input = $this->request->input;
        $result = $this->userService->register($input);
        return app_response(200, $result);
    }

    /**
     * 用户登录
     * @return \think\response\Json
     * @author zws
     */
    public function login()
    {
        $input = $this->request->input;
        $result = $this->userService->login($input);
        return app_response(200, $result);
    }

    /**
     * 找回密码
     * @return \think\response\Json
     * @author zws
     */
    public function getPwd()
    {
        $input = $this->request->input;
        $result = $this->userService->getPwd($input);
        return app_response(200, $result);
    }

    /**
     * 发送验证码
     * @return \think\response\Json
     * @author zws
     */
    public function sendCode()
    {
        $input = $this->request->input;
        $result = $this->userService->sendCode($input);
        return app_response(200, $result);
    }

}